import http from "@/api/config/http";
import { IQuery } from "@/interface/IAxios";
import { Library, RejectData } from "./types";

export function libraryList(query: IQuery) {
  return http.request({
    url: `/library/library/list`,
    method: "get",
    params: query
  });
}

export function createLibrary(data: Library) {
  return http.request({
    url: `/library/library`,
    method: "post",
    data
  });
}

export function updateLibrary(data: Library) {
  return http.request({
    url: `/library/library`,
    method: "put",
    data
  });
}

export function getLibrary(id: string) {
  return http.request({
    url: `/library/library/${id}`,
    method: "get"
  });
}

export const deleteLibrary = (ids: string[]) => {
  return http.request({
    url: `/library/library/${ids.join(",")}`,
    method: "delete"
  });
};

export const libraryThrough = (ids: string[]) => {
  return http.request({
    url: `/library/library/through/${ids.join(",")}`,
    method: "get"
  });
};

export const reject = (data: RejectData) => {
  return http.request({
    url: `/library/library/reject`,
    method: "post",
    data
  });
};

/* 素材管理同步 */
export function librarySync(from: string, to: string) {
  return http.request({
    url: `/library/library/sync`,
    method: "get",
    params: { from, to }
  });
}
